package com.e.library.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.e.library.utils.EGsonUtils;

/**
 * Created by lxy on 2016/12/8.
 */

public class User implements Parcelable {

    /**
     * id : 10
     * level : 0
     * headimgurl : http://i5.hexunimg.cn/2016-09-12/185985253.jpg
     * nickname : 小黄人爱上小黑人0-0
     * imroom_id : 270300716382290352
     * user_id : 48
     * add_time : 1481083347
     */

    private String id;
    private String level;
    private String headimgurl;
    private String nickname;
    private String imroom_id;
    private String user_id;
    private long add_time;
    private String sex;
    private String is_vip;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public String getHeadimgurl() {
        return headimgurl;
    }

    public void setHeadimgurl(String headimgurl) {
        this.headimgurl = headimgurl;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public User() {
    }

    public String getImroom_id() {
        return imroom_id;
    }

    public void setImroom_id(String imroom_id) {
        this.imroom_id = imroom_id;
    }

    public String getUser_id() {
        return user_id;
    }

    public void setUser_id(String user_id) {
        this.user_id = user_id;
    }

    public long getAdd_time() {
        return add_time;
    }

    public void setAdd_time(long add_time) {
        this.add_time = add_time;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getIs_vip() {
        return is_vip;
    }

    public void setIs_vip(String is_vip) {
        this.is_vip = is_vip;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof User)) return false;

        User user = (User) o;

        return getId().equals(user.getId());

    }

    @Override
    public int hashCode() {
        return getId().hashCode();
    }

    public String toJson(){
        return EGsonUtils.obj2Json(this);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.level);
        dest.writeString(this.headimgurl);
        dest.writeString(this.nickname);
        dest.writeString(this.imroom_id);
        dest.writeString(this.user_id);
        dest.writeLong(this.add_time);
        dest.writeString(this.sex);
        dest.writeString(this.is_vip);
    }

    protected User(Parcel in) {
        this.id = in.readString();
        this.level = in.readString();
        this.headimgurl = in.readString();
        this.nickname = in.readString();
        this.imroom_id = in.readString();
        this.user_id = in.readString();
        this.add_time = in.readLong();
        this.sex = in.readString();
        this.is_vip = in.readString();
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel source) {
            return new User(source);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };
}
